using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using DevExpress.XtraReports.UI;

namespace WindowsFormsApplication1
{
    public partial class rptInbangdiemSV : DevExpress.XtraReports.UI.XtraReport
    {
        XRSummary tongsotrinhHK;
        XRSummary TongDiemHK;
        XRSummary tongsotrinhchung;
        XRSummary tongdiemchung;
        int STT = 0;
        public rptInbangdiemSV()
        {
            InitializeComponent();
        }

        public void BindData()
        {
            colHoten.DataBindings.Add("Text", DataSource, "Hoten");
            colMSSV.DataBindings.Add("Text", DataSource, "MasvID");
            colNgaysinh.DataBindings.Add("Text", DataSource, "Ngaysinh", "{0:MM/dd/yyyy}");
            ColNoiSinh.DataBindings.Add("Text", DataSource, "Noisinh");
            colNganh.DataBindings.Add("Text", DataSource, "Tennganh");
            colLophoc.DataBindings.Add("Text", DataSource, "Malop");
            GroupField groupfield = new GroupField("Hocky");
            GroupHeader1.GroupFields.Add(groupfield);
            colHocky.DataBindings.Add("Text", DataSource, "Hocky");
            colMaMH.DataBindings.Add("Text", DataSource, "Mamonhoc");
            colTenMH.DataBindings.Add("Text", DataSource, "Tenmonhoc");
            colSoTC.DataBindings.Add("Text", DataSource, "Sotrinh");
            colDiemL1.DataBindings.Add("Text", DataSource, "DiemL1");
            colDiemL2.DataBindings.Add("Text", DataSource, "DiemL2");
            colDiemL3.DataBindings.Add("Text", DataSource, "DiemL3");

            tongsotrinhHK = new XRSummary();
            xrTableCell3.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", null, "Sotrinh", "") });
            tongsotrinhHK.Running = SummaryRunning.Group;
            xrTableCell3.Summary = tongsotrinhHK;

            TongDiemHK = new XRSummary();
            xrTableCell43.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", null, "Tong", "") });
            TongDiemHK.Running = SummaryRunning.Group;
            xrTableCell43.Summary = TongDiemHK;

            tongsotrinhchung = new XRSummary();
            xrTableCell19.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", null, "Sotrinh", "") });
            tongsotrinhchung.Running = SummaryRunning.Report;
            xrTableCell19.Summary = tongsotrinhchung;

            tongdiemchung = new XRSummary();
            xrTableCell20.DataBindings.AddRange(new XRBinding[] { new XRBinding("Text", null, "Tong", "") });
            tongdiemchung.Running = SummaryRunning.Report;
            xrTableCell20.Summary = tongdiemchung;

        }

        private void colSTT_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            STT++;
            colSTT.Text = STT.ToString();
        }

        private void colTBHK_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            float Sum_Sotrinh = float.Parse(tongsotrinhHK.GetResult().ToString());
            float Sum_diem = float.Parse(TongDiemHK.GetResult().ToString());
            colTBHK.Text = (Sum_diem / Sum_Sotrinh).ToString("n");
        }

        private void colTBChung_BeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e)
        {
            float sotrinhchung = float.Parse(tongsotrinhchung.GetResult().ToString());
            float diemchung = float.Parse(tongdiemchung.GetResult().ToString());
            colTBChung.Text = (diemchung / sotrinhchung).ToString("n");
        }
        

    }
}
